﻿<Views:ViewPage x:Class="PhoneGuitarTab.UI.Views.GenreGroupsView"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:Command="clr-namespace:PhoneCore.Framework.Views.Commands;assembly=PhoneGuitarTab.Core"
               xmlns:Infrastructure="clr-namespace:PhoneGuitarTab.UI.Infrastructure"
               xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"               
               xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
               xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
               xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
               xmlns:Views="clr-namespace:PhoneGuitarTab.Core.Views;assembly=PhoneGuitarTab.Core"
               xmlns:ring="clr-namespace:InTheHand.UI.Xaml.Controls;assembly=InTheHand.UI.Xaml.Controls.ProgressRing"
               xmlns:ui="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI"
               x:Name="root"
               DataContext="{Binding GenreGroups, Source={StaticResource Locator}}"
               FontFamily="{StaticResource PhoneFontFamilyNormal}"
               FontSize="{StaticResource PhoneFontSizeNormal}"
               Foreground="{StaticResource PhoneForegroundBrush}"
               Orientation="Portrait"
               SupportedOrientations="Portrait"
               d:DesignHeight="768"
               d:DesignWidth="480"
               Style="{StaticResource TransitionPageStyle}"
               shell:SystemTray.IsVisible="False"
               mc:Ignorable="d">

    <Views:ViewPage.Resources>
     
       
        <DataTemplate x:Key="PivotHeaderTitleTemplate">
            <ContentPresenter>
                <TextBlock Text="{Binding}" FontSize="40" Margin="0,0,0,0" />
            </ContentPresenter>
        </DataTemplate>
        <Infrastructure:UpperStringConverter x:Name="UpperStr" />
        <Infrastructure:IntToStringConverter x:Name="IntToStr" />
        <Infrastructure:ImageUrlToUriConverter x:Key="ImageUrlToUriConverter"/>
        <Infrastructure:BooleanToVisibilityConverter x:Key="boolVisibility" />

        <DataTemplate x:Key="SuggestedArtistDataTemplate">
            <Grid Margin="10" Height="220" Width="220" HorizontalAlignment="Center">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Image VerticalAlignment="Center" HorizontalAlignment="Center" 
                              Stretch="UniformToFill" MaxHeight="220" MaxWidth="220" Opacity="0.05" Source="/Images/applogo.png">
                </Image>
                <Image VerticalAlignment="Center" HorizontalAlignment="Center"
                           Stretch="UniformToFill"
                           Visibility="Visible" MaxHeight="220" MaxWidth="220" Opacity="0.8">
                    <Image.Source >
                        <BitmapImage UriSource="{Binding ExtraLargeImageUrl, Converter={StaticResource ImageUrlToUriConverter}}"  />
                    </Image.Source>
                </Image>
                <StackPanel  VerticalAlignment="Bottom" HorizontalAlignment="Left">
                    <TextBlock
                                   FontFamily="{StaticResource PhoneFontFamilySemiBold}"
                                   FontSize="20"
                                   Foreground="White"
                                   TextWrapping="Wrap"
                                   Style="{StaticResource PhoneTextLargeStyle}"
                                   Text="{Binding Name}" />
                    <TextBlock
                                   FontFamily="{StaticResource PhoneFontFamilyBold}"
                                   FontSize="20"
                                   Foreground="White"
                                   TextWrapping="Wrap"
                                   Style="{StaticResource PhoneTextLargeStyle}"
                                   />

                </StackPanel>
            </Grid>
        </DataTemplate>

    </Views:ViewPage.Resources>

   

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <Command:ExecuteCommandAction Command="{Binding Search}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <!--  LayoutRoot is the root grid where all page content is placed  -->
    <Grid x:Name="LayoutRoot">
        <!--  Pivot Control  -->
       
        <controls:Pivot x:Name="PivotControl" Margin="{Binding PivotMargin}"
                        Title="{Binding CurrentGenre.Name, Converter={StaticResource UpperStr}}"  TitleTemplate="{StaticResource PivotHeaderTitleTemplate}">
            <controls:PivotItem  >
                <Grid>
                    <ring:ProgressRing x:Name="TabLoadingProgressRing" 
                                       Height="60" Width="60" HorizontalAlignment="Center" Margin="0,-150,0,0"                                  
                                        IsActive="{Binding IsLoading}" >
                    </ring:ProgressRing>
                    <TextBlock x:Name="LoadingTextBlock" VerticalAlignment="Center"
                   HorizontalAlignment="Center"
                   FontFamily="Segoe UI Light"
                   FontSize="24"
                   Opacity="0.5"
                   TextWrapping="Wrap"
                   Foreground="{StaticResource PhoneForegroundBrush}"
                   Text="{Binding Path=LocalizedResources.Discover_LoadingArtists, Source={StaticResource LocalizedStrings}}"
                   Visibility="{Binding IsLoading, Converter={StaticResource boolVisibility}}">
                    </TextBlock>
                    <controls:LongListSelector x:Name="genreArtists" 
                            toolkit:TiltEffect.IsTiltEnabled="True"           
                              Background="Transparent" LayoutMode="Grid" GridCellSize="220,220"         
                              ItemTemplate="{StaticResource SuggestedArtistDataTemplate}"                            
                              ItemsSource="{Binding Groups}">
                    </controls:LongListSelector>

                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Tap">
                            <Command:ExecuteCommandAction Command="{Binding Discover.GoToSuggestedGroup, Source={StaticResource Locator}}" CommandParameter="{Binding ElementName=genreArtists}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Grid>


            </controls:PivotItem>
            <!--controls:Pivot.Background>
                <ImageBrush Stretch="None"  Opacity="0.5" AlignmentX="Center" AlignmentY="Center">
                    <ImageBrush.ImageSource>
                        <BitmapImage UriSource="{Binding Discover.BackGroundImageForGenre, Source={StaticResource Locator}, Converter={StaticResource ImageUrlToUriConverter}}" 
                                     CreateOptions="BackgroundCreation" />
                    </ImageBrush.ImageSource>
                </ImageBrush>
            </-->

        </controls:Pivot>

        <Grid Name="AdContainer">
            <ui:AdControl ApplicationId="398538e9-3217-46b2-90d2-58bd4208d95f" AdUnitId="10867699" HorizontalAlignment="Center" Height="80" VerticalAlignment="Bottom" Width="480" Visibility="{Binding IsAdEnabled, Converter={StaticResource boolVisibility}}"  />
        </Grid>
    </Grid>

   
</Views:ViewPage>